﻿using System;
using System.Collections.Generic;
using ContractManager.Entity;
using Speed.Data;

namespace ContractManager.BLL.Business
{
    public static class ClsExchangeType
    {
        public static List<ExchangeType> SelectAll()
        {
            using (var db = Sys.NewDb())
            {
                return Data.Base.ExchangeType.Select(db);
            }
            
        }

        public static void Insert(ExchangeType capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Insert<ExchangeType>(capital, EnumSaveMode.Requery);
            }
            
        }

        public static void Update(ExchangeType capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Update<ExchangeType>(capital);
            }
            
        }

        public static ExchangeType SelectByPk(Int32 excId)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<ExchangeType>(string.Format("ExcId={0}", excId));
            }
            
        }

        public static ExchangeType SelectByCode(string excCode)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<ExchangeType>(string.Format("ExcCode='{0}'", excCode));
            }
            
        }

        public static int DeleteByPk(Int32 excId)
        {
            using (var db = Sys.NewDb())
            {
                return db.Delete<ExchangeType>(string.Format("ExcId={0}", excId));
            }
            
        }
    }
}